/**
 * 选择命令
 * @param {Function} done
 */
module.exports = function (gulp, plugins, options) {
  return function (done) {
    const inquirer = require('inquirer');
    var choices = []
    for (var i in options.config) {
      choices.push(options.config[i].name)
    }
    inquirer.prompt([{
          type: 'list',
          message: '请选择编译环境：',
          name: 'env',
          choices: choices,
          filter: val => {
            var key = ''
            for (var i in options.config) {
              if (options.config[i].name == val) {
                key = i
                break
              }
            }
            return key
          }
        },
        {
          type: 'confirm',
          message: '是否生成压缩包：',
          name: 'zip',
          default: false,
          when: answers => {
            return answers.env !== 'dev'
          }
        },
        {
          type: 'input',
          message: '请输入压缩包名称：',
          name: 'zipName',
          default: options.pkg.name,
          when: answers => {
            return answers.zip
          }
        }
      ])
      .then(answers => {
        options.answersData = answers;
        options.env = answers.env;
        done()
      });
  };
};